package cac.fenjian.resource.msfactory.rest;

import cac.fenjian.resource.MsFactory.dto.MsFactoryDTO;
import cac.fenjian.resource.msfactory.service.MsFactoryService;
import com.cac.dme.adapter.rest.msg.QueryReqBean;
import com.cac.dme.adapter.rest.msg.ResponseMsg;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program test-curd
 * @description 专业厂配置信息接口
 * @author: LSL
 * @create: 2022-07-11-16-22
 **/
@RestController
@Api(tags = "专业厂配置信息及接口")
@RequestMapping("/MsFactory/")
public class MsFactoryRest {

    @Autowired
    private MsFactoryService msFactoryService;

    /**
     * 新增一条数据
     * @param msFactoryDTO
     * @return
     */
    @PostMapping("save/v1")
    public ResponseMsg<String> insertMsFactoryDTO(@RequestBody MsFactoryDTO msFactoryDTO){
        ResponseMsg<String> responseMsg = new ResponseMsg<>();
        responseMsg.setResponseBody(msFactoryService.insertMsFactoryDTO(msFactoryDTO));
        return responseMsg;
    }

    /**
     * 批量新增数据
     * @param msFactoryRests
     * @return
     */
    @PostMapping("saveBatch/v1")
    public ResponseMsg<Integer> insertBatchMsFactoryDTO(@RequestBody List<MsFactoryDTO> msFactoryRests){
        ResponseMsg<Integer> responseMsg = new ResponseMsg<>();
        responseMsg.setResponseBody(msFactoryService.insertBatchMsFactoryDTO(msFactoryRests));
        return responseMsg;
    }

    /**
     * 根据调价查询数据
     * @param queryReqBean
     * @return
     */
    @PostMapping("searchByParams/v1")
    public ResponseMsg<List<MsFactoryDTO>> searchByParams(@RequestBody QueryReqBean<MsFactoryDTO> queryReqBean){
        ResponseMsg<List<MsFactoryDTO>>  responseMsg = new ResponseMsg<>();
        responseMsg.setResponseBody(msFactoryService.searchByParams(queryReqBean));
        return  responseMsg;
    }

    /**
     * 修改数据
     * @param msFactoryDTO
     * @return
     */
    @PostMapping("updateDate/v1")
    public ResponseMsg<Integer> updateDate(@RequestBody MsFactoryDTO msFactoryDTO){
        ResponseMsg<Integer> responseMsg = new ResponseMsg<>();
        responseMsg.setResponseBody(msFactoryService.updateDate(msFactoryDTO));
        return  responseMsg;
    }

    /**
     * 删除数据
     * @param id
     * @return
     */
    @PostMapping("deleteDate/v1")
    public ResponseMsg<Integer> deleteDate(@RequestBody String id ){
        ResponseMsg<Integer> responseMsg = new ResponseMsg<>();
        responseMsg.setResponseBody(msFactoryService.deleteDate(id));
        return responseMsg;
    }

}
